package com.dong.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JdkSubject implements InvocationHandler {
    private Subject realSubject;

    public JdkSubject(Subject realSubject) {
        this.realSubject = realSubject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before");
        Object result =null;
        try{
           result =   method.invoke(realSubject,args);
        }catch (Exception e ){
            System.out.println("fund exception");
        }finally {
            System.out.println("after");
        }
        return result;

    }
}
